WithDegreeOfParallelism(TSource) Method

Task Parallel System.Threading

Sets the degree of parallelism to use in a query. Degree of parallelism is the maximum number of concurrently executing tasks that will be used to process the query.

Namespace:  System.Linq
Assembly:  System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function WithDegreeOfParallelism(Of TSource) ( _
	source As ParallelQuery(Of TSource), _
	degreeOfParallelism As Integer _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> WithDegreeOfParallelism<TSource>(
	ParallelQuery<TSource> source,
	int degreeOfParallelism
)

Parameters

source
Type: System.Linq..::.ParallelQuery<(Of <(TSource>)>)
A ParallelQuery on which to set the limit on the degrees of parallelism.
degreeOfParallelism
Type: System..::.Int32
The degree of parallelism for the query.

Type Parameters

TSource
The type of elements of source.

Return Value

ParallelQuery representing the same query as source, with the limit on the degrees of parallelism set.

Exceptions

ExceptionCondition
System..::.ArgumentNullException source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException WithDegreeOfParallelism is used multiple times in the query.
System..::.ArgumentOutOfRangeException degreeOfParallelism is less than 1 or greater than 63.

See Also